package basicutil.pipeline;

import java.util.Objects;

/**
 * 基础数据类型实现
 */
public class DataType {
    public static final DataType STRING = new DataType(String.class);
    public static final DataType INTEGER = new DataType(Integer.class);
    public static final DataType DOUBLE = new DataType(Double.class);
    private final String name;
    private final Class<?> typeClass;

    public DataType(String name, Class<?> typeClass) {
        this.name = name;
        this.typeClass = typeClass;
    }
    public DataType(  Class<?> typeClass) {
        this.name = typeClass.getName();
        this.typeClass = typeClass;
    }

    public String getName() {
        return name;
    }

    public Class<?> getTypeClass() {
        return typeClass;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        DataType that = (DataType) obj;
        return Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
